package com.example.dangerouscargodriver.widget;

import android.app.Dialog;
import android.content.Context;
import android.view.Gravity;
import android.view.Window;
import android.view.WindowManager;
import android.view.animation.Animation;
import android.view.animation.AnimationUtils;
import android.view.animation.LinearInterpolator;
import android.view.animation.RotateAnimation;
import android.widget.ImageView;

import com.example.dangerouscargodriver.R;

//public abstract class LoadingDialog extends Dialog {
public class LoadingDialog extends Dialog {
    private ImageView mLoadingView = null;
/*
    public abstract void cancle();
*/
    public LoadingDialog(Context context) {
        super(context, R.style.LoadingDialog);
        // 加载布局
        setContentView(R.layout.layout_loading_dialog);

        mLoadingView = findViewById(R.id.iv_loading);
        // 设置Dialog参数
        Window window = getWindow();
        WindowManager.LayoutParams params = window.getAttributes();
        params.gravity = Gravity.CENTER;
        window.setAttributes(params);

        Animation rotateAnimation = AnimationUtils.loadAnimation(context, R.anim.anim_circle_rotate);
        LinearInterpolator interpolator = new LinearInterpolator();
        rotateAnimation.setInterpolator(interpolator);
        mLoadingView.startAnimation(rotateAnimation);
        setCancelable(false);
    }
/*
    // TODO 封装Dialog消失的回调
    @Override
    public void onBackPressed() {
        // 回调
        cancle();
        // 关闭Loading
        dismiss();
    }
 */
}
